﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using AzureTracer.Services;
using Microsoft.Phone.Shell;
using System.Collections.ObjectModel;
using AzureTracer.Model;
using System.IO.IsolatedStorage;
using AzureTracer.Common;

namespace AzureTracer
{
    public class DataStateManagerEx : DataStateManager
    {
        public static void SaveGlobalDataToState(ILogService LogService)
        {
            PhoneApplicationService.Current.State.Clear();
            PhoneApplicationService.Current.State.Add(LOGSERVICEDATA, LogService.LogList);
        }

        public static void LoadGlobalDataFromState(ILogService LogService)
        {
            object logDataRestore;
            if (PhoneApplicationService.Current.State.TryGetValue(LOGSERVICEDATA, out logDataRestore))
                LogService.LogList = (ObservableCollection<LogEntity>)logDataRestore;
        }

        public static void ResetAll()
        {
            PhoneApplicationService.Current.State.Clear();
            IsolatedStorageSettings.ApplicationSettings.Clear();
            IsolatedStorageHelper.DeleteFile(LOGSERVICEDATA + ".data");
        }
    }
}
